<form id="test-form" action="#0" onsubmit="return false;">
    <p><label>Name: <input name="name"></label></p>
    <p><label>Email: <input name="email"></label></p>
    <p><label>Password: <input name="password" type="password"></label></p>
    <p>Gender: 
        <label><input name="gender" type="radio" value="m" checked=""> Male</label> 
        <label><input name="gender" type="radio" value="f"> Female</label>
    </p>
    <p><label>City: <select name="city">
    	<option value="BJ" selected="">Beijing</option>
    	<option value="SH">Shanghai</option>
    	<option value="CD">Chengdu</option>
    	<option value="XM">Xiamen</option>
    </select></label></p>
    <button type="submit">submit</button>
</form>
<button onclick="test_selector()">RUN</button>


<div id = 'result'>result</div>
<script src = "jquery-3.5.1.slim.js"></script>
<script>
function test_selector()
{
    var json = {};
    $('#test-form [name]').map(function() {
        if(this.name && this.name !== 'gender' || this.checked)
            json[this.name]=this.value;
    });
    var result = JSON.stringify(json);
    $('#result')[0].innerHTML = result;
}

</script>


</script>